import React from 'react';
import { observer } from 'mobx-react';
import * as CONST from 'common/const';

export default function prepareThumbModule(ModuleComponent, mod, maxHeight = CONST.PAGE_HEIGHT) {
  return observer(
    class ThumbModuleHOC extends React.Component {
      static displayName = `ThumbModuleHOC(${mod.type})`;

      // 缩略图模式时，超过最大高度不再渲染更多模块
      render() {
        if (!mod.visible || mod.top > maxHeight) return null;
        mod.isThumb = true;
        const props = {
          mod,
        };
        return (
          <ModuleComponent {...props} />
        );
      }
    }
  );

}
